﻿#include "friendlistitem.h"
#include "ui_friendlistitem.h"
#include <QGridLayout>
#include "utils.h"

FriendListItem::FriendListItem(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::FriendListItem)
{
    ui->setupUi(this);
    lb_usrName = new QLabel("用户名");
    lb_avatar = new QLabel("头像");
    lb_Msg = new QLabel("新信息");
    lb_time = new QLabel("时间");
    lb_NewMsgNum = new QLabel("数量");
    QGridLayout *pLayout = new QGridLayout(this);
    // 0 行 0列开始占 2行2列
    pLayout->addWidget(lb_avatar,0,0,2,1);
    pLayout->addWidget(lb_usrName,0,1,1,2,Qt::AlignLeft | Qt::AlignVCenter);
    pLayout->addWidget(lb_Msg,1,1,1,2, Qt::AlignLeft | Qt::AlignVCenter);
    pLayout->addWidget(lb_time,0,3,1,1,Qt::AlignRight | Qt::AlignVCenter);
    pLayout->addWidget(lb_NewMsgNum,1,3,1,1,Qt::AlignRight | Qt::AlignVCenter);

    lb_avatar->setMaximumSize(50,50);
    lb_usrName->setFont((QFont("Microsoft YaHei", 10, 70)));
    // lb_Msg->setFont((QFont("Microsoft YaHei", 9, 50)));
    lb_Msg->setStyleSheet("QLabel{color:rgb(150,150,154)}");
    utils::setRoundRectImg(lb_avatar,":/img/avatar.png",50);

    this->setStyleSheet("QWidget#FriendListItem{"
                        "background-color:white;"
                        "}"
                        );
}

FriendListItem::~FriendListItem()
{
    delete ui;
}

void FriendListItem::setAvatar(QString imgPath, int radius)
{
    utils::setRoundRectImg(lb_avatar,imgPath,radius);
}

void FriendListItem::setUsrName(QString usrName)
{
    lb_usrName->setText(usrName);
}

void FriendListItem::setMsg(QString Msg)
{
    lb_Msg->setText(Msg);
}

void FriendListItem::setTime(QString time)
{
    lb_time->setText(time);
}

void FriendListItem::setNewMsgNum(QString Num)
{
    lb_NewMsgNum->setText(Num);
}


